package com.qianxing.exceptionhandler;

/**
 * Author:JasonLong
 * Date:2023/5/11
 * Time:17:02
 * 自定义异常类
 */
public class CustomException extends RuntimeException {

    /**
     * 错误码
     */
    private String errorCode;
    /**
     * 错误信息
     */
    private String errorMsg;

    public CustomException() {
    }

    public CustomException(BaseAbnormalResponseInterface baseAbnormalResponseInterface) {
        super(baseAbnormalResponseInterface.getResultCode());
        this.errorCode = baseAbnormalResponseInterface.getResultCode();
        this.errorMsg = baseAbnormalResponseInterface.getResultMsg();
    }

    public CustomException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    //获取状态码
    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    //获取异常返回msg
    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    //调用这个方法时，会重新生成一份堆栈跟踪信息，覆盖原有的堆栈跟踪信息，以便记录当前的异常信息。
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

}
